function nernst

extracellular = 'ACSF_standard';

intracellular = 'K_callaway2';

switch extracellular
case 'ACSF_standard'
    % Extracellular solution: ACSF
    % 127 NaCl, 25 NaHCO3, 2.5 KCl, 4 MgCl2, 4 CaCl2, 1.25 NaH2PO4, 25 D-glucose
    Nao = 127 + 25 + 1.25;
    Ko = 2.5;
    Clo = 127 + 2.5 + 8 + 8;
    Cao = 4;
    Mgo = 4;
    HCO3o = 25;
    H2PO4o = 1.25;
    glucoseo = 25;
end

switch intracellular
case 'K_gordon'
    % Intracellular: EDP Cs-based
    % 120 CsMeSO3, 20 CsCl, 4 NaCl, 10 HEPES, 1 EGTA, 4 Mg2ATP, 
    % 0.3 Na2GTP, 14 Na-phosphocreatine, 3 ascorbate, 0.1 Alexa-594
    Nai = 4 + .6 + 14;
    Ki = 120 +20;
    Cli = 20 + 4;
    Cai = [];
case 'K_ingrid'
    % Intracellular: Ingrid's K-based
    % 120 K-gluconate, 5 NaCl, 2 MgCl2, 0.1 CaCl2, 10 HEPES, 1.1 EGTA, 
    % 4 Mg2ATP, and 0.4 Na2GTP, 15 Na-phosphocreatine
    Nai = 5 + .8 + 15;
    Ki = 120;
    Cli = 5 + 4 + .2;
    Cai = .1;
    Mgi = 2 + 4;
case 'K_callaway1'
    % pnas paper
    % 170 K-gluconate, 10 Hepes, 10 NaCl, 2 MgCl2, 0.5 EGTA
    % 0.1 CaCl2, 3.5 Mg-ATP, 1 Li-GTP
    Nai = 10;
    Ki = 170;
    Cli = 10+4+.2;
case 'K_callaway2'
    % sawatari neuron paper
    % 130 mM potassium gluconate, 1 mM EGTA, 2 mM MgCl2, 
    % 0.5 mM CaCl2, 2.54 mM ATP, and 10 mM HEPES 
    Nai = 1;
    Ki = 130;
    Cli = 4 + 1;
end

% constants
constA = 25.26; % RT/F for ln version of nernst, room temp
constB = 58.17; % log10 version, room temp

% equilibribrium potentials
% nersnt equation: Ex = RT/zF * ln(Xo/Xi)
clc;
disp(' ');
disp(['For intracellular solution called: ' intracellular]);
E_Cl = constA/(-1) * log(Clo/Cli);
disp(['Equilibrium potential for chloride is: ' num2str(round(E_Cl))]);
E_K = constA * log(Ko/Ki);
disp(['Equilibrium potential for potassium is: ' num2str(round(E_K))]);
E_Na = constA * log(Nao/Nai);
disp(['Equilibrium potential for sodium is: ' num2str(round(E_Na))]);
